home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / 92052tar.gz / 920528.tar / lapb.h < prev    next >
C/C++ Source or Header  |  1991-05-10  |  6KB  |  151 lines

  1. /* @(#) $Header: lapb.h,v 1.10 91/05/09 07:38:32 deyke Exp $ */
  2.  
  3. #ifndef _LAPB_H
  4. #define _LAPB_H
  5.  
  6. #ifndef _GLOBAL_H
  7. #include "global.h"
  8. #endif
  9.  
  10. #ifndef _MBUF_H
  11. #include "mbuf.h"
  12. #endif
  13.  
  14. #ifndef _IFACE_H
  15. #include "iface.h"
  16. #endif
  17.  
  18. #ifndef _TIMER_H
  19. #include "timer.h"
  20. #endif
  21.  
  22. #ifndef _AX25_H
  23. #include "ax25.h"
  24. #endif
  25.  
  26. /* Upper sub-layer (LAPB) definitions */
  27.  
  28. /* Control field templates */
  29. #define I       0x00    /* Information frames */
  30. #define S       0x01    /* Supervisory frames */
  31. #define RR      0x01    /* Receiver ready */
  32. #define RNR     0x05    /* Receiver not ready */
  33. #define REJ     0x09    /* Reject */
  34. #define U       0x03    /* Unnumbered frames */
  35. #define SABM    0x2f    /* Set Asynchronous Balanced Mode */
  36. #define DISC    0x43    /* Disconnect */
  37. #define DM      0x0f    /* Disconnected mode */
  38. #define UA      0x63    /* Unnumbered acknowledge */
  39. #define FRMR    0x87    /* Frame reject */
  40. #define UI      0x03    /* Unnumbered information */
  41. #define PF      0x10    /* Poll/final bit */
  42.  
  43. #define MMASK   7       /* Mask for modulo-8 sequence numbers */
  44.  
  45. /* FRMR reason bits */
  46. #define W       1       /* Invalid control field */
  47. #define X       2       /* Unallowed I-field */
  48. #define Y       4       /* Too-long I-field */
  49. #define Z       8       /* Invalid sequence number */
  50.  
  51. /* AX25 protocol constants */
  52. #define DST_C   1               /* Set C bit in dest addr */
  53. #define SRC_C   2               /* Set C bit in source addr */
  54. #define VERS1   0               /* AX25L2V1 compatible frame */
  55. #define CMD     (DST_C)         /* Command frame */
  56. #define POLL    (DST_C|PF)      /* Poll frame */
  57. #define RESP    (SRC_C)         /* Response frame */
  58. #define FINAL   (SRC_C|PF)      /* Final frame */
  59.  
  60. /* Round trip timing parameters */
  61. #define AGAIN   8               /* Average RTT gain = 1/8 */
  62. #define DGAIN   4               /* Mean deviation gain = 1/4 */
  63.  
  64. /* AX25 connection control block */
  65. struct ax25_cb {
  66.   struct ax25 hdr;              /* AX25 header */
  67.   struct iface *ifp;            /* Pointer to interface structure */
  68.   int  state;                   /* Connection state */
  69. #define DISCONNECTED  0
  70. #define CONNECTING    1
  71. #define CONNECTED     2
  72. #define DISCONNECTING 3
  73.   int  reason;                  /* Reason for disconnecting */
  74. #define NORMAL        0         /* Normal disconnect */
  75. #define RESET         1         /* Disconnected by other end */
  76. #define TIMEOUT       2         /* Excessive retransmissions */
  77. #define NETWORK       3         /* Network problem */
  78.   int  mode;                    /* Connection mode */
  79. #define STREAM        0
  80. #define DGRAM         1
  81.   int  closed;                  /* Disconnect when send queue empty */
  82.   int  polling;                 /* Poll frame has been sent */
  83.   int  rnrsent;                 /* RNR frame has been sent */
  84.   int  rejsent;                 /* REJ frame has been sent */
  85.   int32 remote_busy;            /* Other end's window is closed */
  86.   int  vr;                      /* Incoming sequence number expected next */
  87.   int  vs;                      /* Next sequence number to be sent */
  88.   int  cwind;                   /* Congestion window */
  89.   int  retry;                   /* Retransmission retry count */
  90.   int32 srtt;                   /* Smoothed round trip time, milliseconds */
  91.   int32 mdev;                   /* Mean deviation, milliseconds */
  92.   struct timer timer_t1;        /* Retransmission timer */
  93.   struct timer timer_t2;        /* Acknowledgement delay timer */
  94.   struct timer timer_t3;        /* No-activity timer */
  95.   struct timer timer_t4;        /* Busy timer */
  96.   struct timer timer_t5;        /* Packet assembly timer */
  97.   struct axreseq {              /* Resequencing queue */
  98.     struct mbuf *bp;
  99.     int  sum;
  100.   } reseq[8];
  101.   struct mbuf *rcvq;            /* Receive queue */
  102.   int16 rcvcnt;                 /* Receive queue length */
  103.   struct mbuf *sndq;            /* Send queue */
  104.   int32 sndqtime;               /* Last send queue write time */
  105.   struct mbuf *resndq;          /* Resend queue */
  106.   int  unack;                   /* Number of unacked frames */
  107.   int32 sndtime[8];             /* Time of 1st transmission */
  108.   void (*r_upcall) __ARGS((struct ax25_cb *p, int cnt));
  109.                 /* Call when data arrives */
  110.   void (*t_upcall) __ARGS((struct ax25_cb *p, int cnt));
  111.                 /* Call when ok to send more data */
  112.   void (*s_upcall) __ARGS((struct ax25_cb *p, int oldstate, int newstate));
  113.                 /* Call when connection state changes */
  114.   char  *user;                  /* User parameter (e.g., for mapping to an
  115.                  * application control block)
  116.                  */
  117.   struct ax25_cb *peer;         /* Pointer to peer's control block */
  118.   struct ax25_cb *next;         /* Linked-list pointer */
  119. };
  120.  
  121. #define NULLAXCB ((struct ax25_cb *) 0)
  122.  
  123. extern char  *ax25reasons[];            /* Reason names */
  124. extern char  *ax25states[];             /* State names */
  125. extern int  ax_maxframe;                /* Transmit flow control level */
  126. extern int  ax_paclen;                  /* Maximum outbound packet size */
  127. extern int  ax_pthresh;                 /* Send polls for packets larger than this */
  128. extern int  ax_retry;                   /* Retry limit */
  129. extern int32 ax_t1init;                 /* Retransmission timeout */
  130. extern int32 ax_t2init;                 /* Acknowledgement delay timeout */
  131. extern int32 ax_t3init;                 /* No-activity timeout */
  132. extern int32 ax_t4init;                 /* Busy timeout */
  133. extern int32 ax_t5init;                 /* Packet assembly timeout */
  134. extern int  ax_window;                  /* Local flow control limit */
  135. extern struct ax25_cb *axcb_server;     /* Server control block */
  136.  
  137. /* In lapb.c: */
  138. int lapb_input __ARGS((struct iface *iface, struct ax25 *hdr, struct mbuf *bp));
  139. int doax25 __ARGS((int argc, char *argv [], void *p));
  140. struct ax25_cb *open_ax __ARGS((char *path, int mode, void (*r_upcall )__ARGS ((struct ax25_cb *p, int cnt )), void (*t_upcall )__ARGS ((struct ax25_cb *p, int cnt )), void (*s_upcall )__ARGS ((struct ax25_cb *p, int oldstate, int newstate )), char *user));
  141. int send_ax __ARGS((struct ax25_cb *cp, struct mbuf *bp));
  142. int space_ax __ARGS((struct ax25_cb *cp));
  143. int recv_ax __ARGS((struct ax25_cb *cp, struct mbuf **bpp, int cnt));
  144. int close_ax __ARGS((struct ax25_cb *cp));
  145. int reset_ax __ARGS((struct ax25_cb *cp));
  146. int del_ax __ARGS((struct ax25_cb *cp));
  147. int valid_ax __ARGS((struct ax25_cb *cp));
  148. int kick_ax __ARGS((struct ax25_cb *cp));
  149.  
  150. #endif  /* _LAPB_H */
  151.